package com.pw.study.flink.demo

import org.apache.flink.api.scala._

object WordCountV1 {
  def main(args: Array[String]): Unit = {
    //1.启动环境
    val env: ExecutionEnvironment = ExecutionEnvironment.getExecutionEnvironment
    //2.输入数据
    val fs: DataSet[String] = env.readTextFile("data/file/hello.txt")
    //3.处理数据
    val words: DataSet[String] = fs.flatMap(_.split(""))
    val wordAndOne: DataSet[(String, Int)] = words.map((_, 1))
    val dealData: AggregateDataSet[(String, Int)] = wordAndOne.groupBy(0).sum(1)


    //4.输出数据
    dealData.print()
    //5.执行


  }
}
